/**
 * 
 */
package com.seedwill.common.query;

import com.seedwill.common.meta.DataType;


/**
 * 标量查询配置
 * @author kdyi
 *
 */
public class ScalarQueryConfig {
	
	/**
	 * 唯一SQL命令
	 */
	public static final String distinctCmd = "distinct";
	
	/**
	 * 唯一SQL命令带空格
	 */
	public static final String distinctCmdSpaced = distinctCmd+" ";
	/**
	 * 预定义的AS COUNT字段，用于注册标量返回
	 */
	public static final String  countField = "counter_";
	/**
	 * 预定义的COUNT函数，用于简单的查询语句校验
	 */
	public static final String  countFuncClause = " count(";
	public static final String  defaultSqaCountElement = "*";
	public static final String  defaultSqaClose = ") ";
	public static final String  defaultSelectCmd = "select ";
	/**
	 * 预定义的COUNT返回语句 用于简单的查询语句校验
	 */
	public static final String  countFieldClause = " as "+countField;
	/**
	 * 默认返回的标量数据类型 字符串类型
	 */
	public static final DataType defaultObjType = DataType.STRING;
	/**
	 * 预定义的AS OBJECT字段，用于注册标量返回
	 */
	public static final String  objField = "obj_";
	/**
	 * 预定义的OBJECT返回语句 用于简单的查询语句校验
	 */
	public static final String  objFieldClause = " as "+objField;
	
	/**
	 * 默认的COUNT查询 select count(*) as counter_
	 */
	public static final String  defaultCountClause = defaultSelectCmd+countFuncClause+defaultSqaCountElement+defaultSqaClose+countFieldClause;
	
	/**
	 * 构造COUNT语句
	 * @param countElement
	 * @return
	 */
	public static String  countClause(String countElement){
		return defaultSelectCmd+countFuncClause+countElement+defaultSqaClose+countFieldClause;
	}
}
